package com.shijie99.paper.manage.service.imp;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.shijie99.paper.manage.dao.PmPolicyInfoMapper;
import com.shijie99.paper.manage.dao.PmPolicyLimitDateMapper;
import com.shijie99.paper.manage.dao.PmPolicyLimitMapper;
import com.shijie99.paper.manage.dao.PmPolicyRefundMapper;
import com.shijie99.paper.manage.pojo.PmPolicyInfo;
import com.shijie99.paper.manage.pojo.PmPolicyLimit;
import com.shijie99.paper.manage.pojo.PmPolicyLimitDate;
import com.shijie99.paper.manage.pojo.PmPolicyRefund;
import com.shijie99.paper.manage.service.PaperOrderService;


@Service("paperOrderService")
public class PaperOrderServiceImpl implements PaperOrderService {

	private static Logger logger = Logger.getLogger(PaperOrderServiceImpl.class);
	
	@Autowired
	private PmPolicyInfoMapper pmPolicyInfoMapper;
	
	@Autowired
	private PmPolicyLimitDateMapper pmPolicyLimitDateMapper;
	
	@Autowired
	private PmPolicyLimitMapper pmPolicyLimitMapper; 
	
	@Autowired
	private PmPolicyRefundMapper pmPolicyRefundMapper;

	
	
	@Override
	@Transactional(rollbackFor=Exception.class)
	public void addPaperOrder(PmPolicyInfo pmPolicyInfo,
			PmPolicyLimit pmPolicyLimit, PmPolicyLimitDate pmPolicyLimitDate,
			PmPolicyRefund pmPolicyRefund) {
	
		try {
			pmPolicyInfoMapper.insertSelective(pmPolicyInfo);
			pmPolicyLimitMapper.insertSelective(pmPolicyLimit);
			pmPolicyLimitDateMapper.insertSelective(pmPolicyLimitDate);
			pmPolicyRefundMapper.insertSelective(pmPolicyRefund);
		} catch (Exception e) {
			logger.error("保存纸单政策信息出错",e);
//			map.put(Constant.KEY_STATUS, Constant.STATUS_ERROR);
//			map.put(Constant.KEY_MSG, "保存用户信息时出现错误，请找管理人员解决!");
			throw e;
		}
		
	}
	

}
